import org.antlr.v4.runtime.CharStreams;

public class Wiki生成器 {
    
    public static String 生成(String source){
        var buffer = new StringBuffer();
        buffer.append(网页头());

        var stream = CharStreams.fromString(source);
        var wiki = new Wiki(stream);
        wiki.buffer = buffer;
        var token = wiki.nextToken();
        while (token.getType() != WikiLexerBase.EOF) {
            token = wiki.nextToken();
//            System.out.println("token: " + token);
        }

        buffer.append(网页尾());
        return buffer.toString();
    }
    
    private static String 网页头(){
        return "<HTML>\r\n"+
                "<HEAD>\r\n"+
                "<meta http-equiv=content-type content=\"text/html; charset=utf-8\"/>\r\n"+
                "<link rel=stylesheet href=http://www.cs.usfca.edu/~parrt/lecture-wiki.css "+
                "type=\"text/css\"/>\r\n"+
                "</HEAD>\r\n"+
                "<BODY>\r\n";
    }

    private static String 网页尾(){
        return "</BODY>\r\n"+
                "</HTML>\r\n";
    }
    
    
}
